package com.yzjs.config;


import java.io.*;
import java.security.KeyStore;
import javax.net.ssl.SSLContext;
import org.apache.http.ssl.SSLContexts;
import org.apache.tomcat.util.http.fileupload.IOUtils;

public class WxPayConfig extends PayConfig {
    private String appId;
    private String appSecret;
    private String miniAppId;
    private String appAppId;
    private String mchId;
    private String mchKey;
    private String keyPath;
    private SSLContext sslContext;

    public SSLContext initSSLContext() {
        InputStream inputStream = WxPayConfig.class.getClassLoader().getResourceAsStream(this.getKeyPath());
           // String filePath = wx.getClass().getResource("/"+this.getKeyPath()).getPath();
           // System.out.println(filePath);
           //  inputStream = new FileInputStream(new File(filePath));


        SSLContext var4;
        try {
            KeyStore keystore = KeyStore.getInstance("PKCS12");
            char[] partnerId2charArray = this.mchId.toCharArray();
            keystore.load(inputStream, partnerId2charArray);
            this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build();
            var4 = this.sslContext;
        } catch (Exception var9) {
            throw new RuntimeException("证书文件有问题，请核实！", var9);
        } finally {
            IOUtils.closeQuietly(inputStream);
        }

        return var4;
    }

    public WxPayConfig() {
    }

    public String getAppId() {
        return this.appId;
    }

    public String getAppSecret() {
        return this.appSecret;
    }

    public String getMiniAppId() {
        return this.miniAppId;
    }

    public String getAppAppId() {
        return this.appAppId;
    }

    public String getMchId() {
        return this.mchId;
    }

    public String getMchKey() {
        return this.mchKey;
    }

    public String getKeyPath() {
        return this.keyPath;
    }

    public SSLContext getSslContext() {
        return this.sslContext;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public void setMiniAppId(String miniAppId) {
        this.miniAppId = miniAppId;
    }

    public void setAppAppId(String appAppId) {
        this.appAppId = appAppId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    public void setMchKey(String mchKey) {
        this.mchKey = mchKey;
    }

    public void setKeyPath(String keyPath) {
        this.keyPath = keyPath;
    }

    public void setSslContext(SSLContext sslContext) {
        this.sslContext = sslContext;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof WxPayConfig)) {
            return false;
        } else {
            WxPayConfig other = (WxPayConfig)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label107: {
                    Object this$appId = this.getAppId();
                    Object other$appId = other.getAppId();
                    if (this$appId == null) {
                        if (other$appId == null) {
                            break label107;
                        }
                    } else if (this$appId.equals(other$appId)) {
                        break label107;
                    }

                    return false;
                }

                Object this$appSecret = this.getAppSecret();
                Object other$appSecret = other.getAppSecret();
                if (this$appSecret == null) {
                    if (other$appSecret != null) {
                        return false;
                    }
                } else if (!this$appSecret.equals(other$appSecret)) {
                    return false;
                }

                Object this$miniAppId = this.getMiniAppId();
                Object other$miniAppId = other.getMiniAppId();
                if (this$miniAppId == null) {
                    if (other$miniAppId != null) {
                        return false;
                    }
                } else if (!this$miniAppId.equals(other$miniAppId)) {
                    return false;
                }

                label86: {
                    Object this$appAppId = this.getAppAppId();
                    Object other$appAppId = other.getAppAppId();
                    if (this$appAppId == null) {
                        if (other$appAppId == null) {
                            break label86;
                        }
                    } else if (this$appAppId.equals(other$appAppId)) {
                        break label86;
                    }

                    return false;
                }

                label79: {
                    Object this$mchId = this.getMchId();
                    Object other$mchId = other.getMchId();
                    if (this$mchId == null) {
                        if (other$mchId == null) {
                            break label79;
                        }
                    } else if (this$mchId.equals(other$mchId)) {
                        break label79;
                    }

                    return false;
                }

                label72: {
                    Object this$mchKey = this.getMchKey();
                    Object other$mchKey = other.getMchKey();
                    if (this$mchKey == null) {
                        if (other$mchKey == null) {
                            break label72;
                        }
                    } else if (this$mchKey.equals(other$mchKey)) {
                        break label72;
                    }

                    return false;
                }

                Object this$keyPath = this.getKeyPath();
                Object other$keyPath = other.getKeyPath();
                if (this$keyPath == null) {
                    if (other$keyPath != null) {
                        return false;
                    }
                } else if (!this$keyPath.equals(other$keyPath)) {
                    return false;
                }

                Object this$sslContext = this.getSslContext();
                Object other$sslContext = other.getSslContext();
                if (this$sslContext == null) {
                    if (other$sslContext != null) {
                        return false;
                    }
                } else if (!this$sslContext.equals(other$sslContext)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof WxPayConfig;
    }



    public String toString() {
        return "WxPayConfig(appId=" + this.getAppId() + ", appSecret=" + this.getAppSecret() + ", miniAppId=" + this.getMiniAppId() + ", appAppId=" + this.getAppAppId() + ", mchId=" + this.getMchId() + ", mchKey=" + this.getMchKey() + ", keyPath=" + this.getKeyPath() + ", sslContext=" + this.getSslContext() + ")";
    }
}
